package com.bobamrz.dao;

import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

import org.hibernate.Query;
import org.hibernate.Session;

import com.bobamrz.domain.DocType;
import com.bobamrz.hibernate.HibernateUtil;

public class DocTypeHomeExt {

	private Session session = HibernateUtil.getSessionFactory().getCurrentSession();
	
	public DocType findByName(String name) {
		if(session.isOpen()){
			System.err.println("a");
		} else {
			System.err.println("b");
		}
		String hql = "FROM DocType WHERE typeName = '" + name+"'";
		Query query = session.createQuery(hql);
		List<DocType> results = query.list();
		if (results.size() > 0) {
			return results.get(0);
		} else {
			return null;
		}
	}

}
